#define _CRT_SECURE_NO_WARNINGS 1
#include <utility>
#include <climits>
#include <stack>
using namespace std;
using pii = pair<int, int>;
class StockSpanner {
public:
    StockSpanner()
        :idx(-1)
    {
        st.emplace(-1, INT_MAX);
    }

    int next(int price)
    {
        ++idx;
        while (!st.empty() && st.top().second <= price)
        {
            st.pop();
        }
        int span = idx - st.top().first;
        st.emplace(idx, price);
        return span;
    }
private:
    stack<pii> st;
    int idx;
};

/**
 * Your StockSpanner object will be instantiated and called as such:
 * StockSpanner* obj = new StockSpanner();
 * int param_1 = obj->next(price);
 */